package hu.elte.inf.holiuml.model;

import java.awt.Graphics;

/**
 * @author Csaba Hoch
 */
public class ObjectNode extends Node {
	
	/**
	 * The UML object that belongs to this node.
	 */
	private UMLObject umlObject;
	
	/**
	 * If true, the attributes of the class should be displayed.
	 */
	private boolean visibleAttributes;

	public ObjectNode() {
	}
	
	public ObjectNode(ObjectNode objectNode) {
		this.visibleAttributes = new Boolean(objectNode.isVisibleAttributes());
		this.umlObject = new UMLObject(objectNode.getUMLObject());
	}

	/**
	 * The lines will contain the name and the class of the object, and the
	 * attributes if they are visible.
	 */
	@Override
	protected void recalculateLines(Graphics g) {
		lines.add(umlObject.getName() + " : "
				+ umlObject.getUMLClass().getName());
		if (visibleAttributes) {
			lines.add(null);
			for (Attribute attr : umlObject.getUMLClass().getAttributes()) {
				lines.add(attr.toString());
			}
		}
	}

	public UMLObject getUMLObject() {
		return umlObject;
	}

	public void setUMLObject(UMLObject umlObject) {
		this.umlObject = umlObject;
	}

	public boolean isVisibleAttributes() {
		return visibleAttributes;
	}

	public void setVisibleAttributes(boolean visibleAttributes) {
		this.visibleAttributes = visibleAttributes;
	}
}
